<template>
  <div id="recommended_list">
    <!-- 头部 -->
    <div class="title">
      <div class="left">
        <h3>推荐歌单</h3>
      </div>
      <div
        class="right"
        @click="toPlayLists"
      >
        更多
        <span class="iconfont icon-youjiantou"></span>
      </div>
    </div>
    <!-- 主题内容 -->
    <div class="list_main">
      <ul class="main_card">
        <li
          class="card_list__item"
          v-for="(item,index) in recommonlist"
          :key="index"
          @click="pushPlayList(item.id)"
        >
          <div class="item_top">
            <img
              :src="item.picUrl"
              :title="item.name"
            >
          </div>
          <div class="item_title">
            {{item.name}}
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "recommomlist",
  data() {
    return {
      //推荐歌单音乐厅页面加载项
      recommonlist: []
    };
  },
  // 自执行加载推荐歌单
  created() {
    axios({
      url: "https://autumnfish.cn/personalized",
      method: "get",
      params: {
        // 获取的数据量
        limit: 8
      }
    }).then(res => {
      // console.log(res)
      this.recommonlist = res.data.result;
    });
  },
  methods: {
    toPlayLists() {
      this.$router.push("/playLists");
    },
    pushPlayList: function(id) {
      // 跳转到歌单详情页面
      this.$router.push(`/playList?id=${id}`);
    }
  }
};
</script>

<style lang="scss">
#recommended_list {
  overflow: hidden;
  margin-top: 20px;
  cursor: pointer !important;
  .title {
    height: 30px;
    // background-color: hotpink;
    line-height: 30px;
    .left {
      float: left;
      padding-left: 6%;
    }
    .right {
      float: right;
      padding-right: 6%;
      &:hover {
        color: yellowgreen;
      }
    }
  }
  .list_main {
    margin-top: 20px;
    padding: 0px 30px;
    ul.main_card {
      // height: 200px;
      overflow: hidden;
      li.card_list__item {
        float: left;
        width: 12.5%;
        margin-bottom: 20px;
        padding-right: 10px;
        box-sizing: border-box;
        // color: white;
        .item_top {
          padding: 10px;
          img {
            width: 100%;
            border-radius: 5px;
          }
        }
        .item_title {
          padding: 0px 10px;
          max-height: 16px;
          font-size: 15px;
          text-align: center;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
}
</style>